package com.example.springbootplm.service.impl;

import com.example.springbootplm.mapper.EmpMapper;
import com.example.springbootplm.pojo.Emp;
import com.example.springbootplm.pojo.Emp1;
import com.example.springbootplm.pojo.PageBean;
import com.example.springbootplm.service.EmpService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    //传统的分页查询
   @Override
    public PageBean page(Integer page, Integer pageSize) {
        Long count = empMapper.count();

        Integer start = (page-1)*pageSize;
        List<Emp> empList = empMapper.page(start,pageSize);

        PageBean pageBean = new PageBean(count,empList);
        return pageBean;
    }
    //PageHelper分页插件
  /*  @Override
    public PageBean page(Integer page, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);

        //执行查询
        List<Emp> empList = empMapper.list();
        Page<Emp> p = (Page<Emp>) empList;

        //封装Pagebean
        PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }*/

    /*@Override
    public PageBean page(Integer page, Integer pageSize, String name , Integer age , LocalDate begin, LocalDate end) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);

        //执行查询
        List<Emp> empList = empMapper.list(name,age,begin,end);
        Page<Emp> p = (Page<Emp>) empList;

        //封装Pagebean
        PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }*/


    //批量删除
//    @Override
//    public void delete(List<Integer> ids) {
//       //empMapper.delete(ids);
//    }

    //新增员工
    @Override
    public void save(Emp emp) {
        //empMapper.insert(emp);
    }

    @Override
    public Emp1 login(Emp1 emp1) {
        return null;
    }

    //登录

}
